package com.example.shopspring.Controller;


import com.example.shopspring.Model.Product;
import com.example.shopspring.Service.ProductService;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/products")
@CrossOrigin
public class ProductController {
    private final ProductService productService;

    public ProductController(ProductService productService) {
        this.productService = productService;
    }

    //获取商品地址：http://localhost:8080/products/getProductList
    @GetMapping("getProductList")
    public ResponseEntity<?> getProductList(String genre) {
        List<Product> productList=productService.getProductListByGenres(genre);
        return ResponseEntity.ok(productList);
    }
}
